package com.general.common.utils;

import com.general.common.utils.spring.SpringUtils;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

public class AsyncTaskHelper {

    private AsyncTaskHelper() { }

    private static final AsyncTaskHelper helper = new AsyncTaskHelper();

    private final ThreadPoolTaskExecutor threadPoolTaskExecutor = SpringUtils.getBean("threadPoolTaskExecutor");

    public static AsyncTaskHelper getInstance() {
        return helper;
    }

    public void execute(Runnable runnable) {
        if (runnable != null) {
            threadPoolTaskExecutor.execute(runnable);
        }
    }

}